package org.example.game.weekly.game441;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: TODO
 * @Author wyatt
 * @Data 2024/08/03 20:46
 */
public class Solution001 {

    public static void main(String[] args) {
        System.out.println(new Solution001().maxSum(new int[]{-1,-2,1}));
    }

    public int maxSum(int[] nums) {
        int sum = 0;
        int max = Integer.MIN_VALUE;
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < nums.length; i++) {
            max = Math.max(max, nums[i]);
            if(nums[i] >= 0 && !list.contains(nums[i])){
                sum += nums[i];
                list.add(nums[i]);
            }
        }
        return sum == 0 ? max : sum;
    }
}
